package com.wlhse.controller;

import com.wlhse.dto.outDto.CheckListOutDto;
import com.wlhse.entity.CheckListPojo;
import com.wlhse.service.CheckListService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("CheckListController")
@RequestMapping("/api/v1")
public class CheckListController {
    @Resource
    private CheckListService checkListService;

    //分页查询所有检查表
    @RequestMapping(value = "/queryCheckList", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String queryCheckList(@RequestParam(value = "checkListName",required = false) String checkListName,
                                 @RequestParam(value = "num",required = false) Integer num,
                                 @RequestParam(value = "size",required = false) Integer size) {
        return checkListService.queryCheckList(checkListName,num,size);
    }

    //新增检查表(不用，可以使用以前的接口api/v1/check_list_excel_upload)
//    @RequestMapping(value = "/addCheckList", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
//    public String addCheckList(@RequestBody CheckListPojo checkListPojo) {
//        return checkListService.addCheckList(checkListPojo);
//    }

    //启用、停用检查表
    @RequestMapping(value = "/updateCheckList", method = RequestMethod.PUT, produces = "application/json; charset=utf-8")
    public String updateCheckList(@ModelAttribute CheckListPojo checkListPojo) {
        return checkListService.updateCheckList(checkListPojo);
    }

    //查询检查表使用的dictcode
    @RequestMapping(value = "/queryCheckListDictCode", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
    public String queryCheckListDictCode() {
        return checkListService.queryCheckListDictCode();
    }

    //修改检查表的检查内容或检查表名
    @RequestMapping(value = "/updateCheckListDictCode", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
    public String updateCheckListDictCode(@RequestBody CheckListOutDto checkListOutDto) {
        return checkListService.updateCheckListDictCode(checkListOutDto);
    }
}
